
#include "sqlite.hpp"
#include <cassert>
//                                  多少列          记录             字段名
int select_stu_callback(void* arg, int col_count, char** result, char** fileds_name)
{
    std::vector<std::string>* array = (std::vector<std::string>*)arg;
    for(int i = 0; i < col_count; i++)
      array->push_back(result[i]);


    return 0;
}

int main()
{
    SqliteHelper helper("./test.db");
    assert(helper.open());

    // const char* ct = "create table if not exists student(sn int primary key, name varchar(32), age int);";
    // assert(helper.exec(ct, nullptr, nullptr));
    // const char* insert_sql = "insert into student values(1, '小明', 18), (2, '小黑', 19), (3, '小红', 18);";
    // assert(helper.exec(insert_sql, nullptr, nullptr));

    const char* select_sql = "select * from student";
    std::vector<std::string> array;
    assert(helper.exec(select_sql, select_stu_callback, &array));

    for(auto& name : array)
    {
        std::cout << name << std::endl;
    }

    helper.close();
    return 0;
}